<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title><% model(2); %></title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="config.js"></script>
<script type="text/javascript" src="general.js"></script>
<script type="text/javascript">
	var modemInfo;
	var col_ar=["loc", "vid", "pid", "type", "data", "ui", "manuf", "prod"];

	function get_syscmd_out(xhr)
	{
		var url = "http://"+window.location.host+"/syscmd_out.asp";
		getHTTPRequest( url, fill_table );
	}
	function fill_table(xhr)
	{
		generate_table(xhr.responseText);
	}
	function get_html()
	{
		var url=getCmdExecUrl( window.location.host, "lsmodem -j" );
		getHTTPRequest( url, get_syscmd_out );
	}
	function onfail()
	{
		self.close();
	}

	function generate_table( data_str )
	{
		var str="<table class='sel_devpath'>\n\
			<tr><th>USB<br>Location<\/th><th colspan='2'>VID/PID<\/th><th>Type<\/th><th>Data<br>port<\/th><th>User<br>interface<br>port<\/th><th colspan='2'>Info<\/th><\/tr>";
		var ar=eval(data_str);
		if( ar ){
		    modemInfo=ar;
		    for(var i=0; i<ar.length; i++){
			var item=ar[i];
			if(!item) continue;
			str+="<tr>";
			for(var j=0;j<col_ar.length;j++){
			    str+="<td onclick='select_td(this)' onmouseover='fill_row(this, 1)' onmouseout='fill_row(this, 0)'>";
			    str+=item[col_ar[j]];
			    str+="<\/td>";
			}
			str+="<\/tr>";
		    }
		}
		str+="<\/table>";

		document.getElementById("tb1").innerHTML=str;
	}
	function select_td(el)
	{
		var row=el.parentNode;
		var loc=row.children[0].innerHTML;
		var ar=modemInfo;
		for(var i=0; i<ar.length; i++){
			if(ar[i] && ar[i].loc==loc){
				opener.changeUSBparams( ar[i] );
				break;
			}
		}
		self.close();
	}
	function fill_row(el, fill){
		var row=el.parentNode;
		if( fill === 0 ){
			row.bgColor="#FFFFFF";
		} else {
			row.bgColor="#6666FF";
		}
	}
	$(document).ready(function() {
		// load_body();
		get_html();
	});
</script>
</head>
<body>
		<div id="tb1" style="text-align:center; vertical-align:middle;"><span style="font-size:32px;">Please wait...</span></div>
</body>
</html>
